<?php  if ( ! defined('BASEPATH')) exit('No direct script access allowed');
class Lock_list_Model extends CI_Model{
    function __construct()
    {
        parent::__construct();
    }
    function getAllData($num,$offset){
        $query = $this->db->get('lock_list',$num,$offset);
      
        return $query->result();  
    }
    
    function getNumData(){
        $query = $this->db->get('lock_list');
        return $query->num_rows();
    }
     function get_object($id)
    {
        $query = $this->db->get_where('lock_list', array('lock_list_id' =>$id));
        return $query->row();
    }
    function delete($id){
          $this->db->where('lock_list_id',$id);
          $query = $this->db->delete('lock_list');
          if($query){
              return true;
          }else{
              return false;
          }
    }
	function deleted($id){
          $this->db->where('lock_list_id',$id);
		  $data=array('bl_active'=>'-1');
          $query = $this->db->update('lock_list',$data);
          if($query){
              return true;
          }else{
              return false;
          }
    }
    
    function get_list_permit(){
        return $this->db->get('permission')->result();
    }
  
  
   

   function saveData($category_news_id,$data){
             if($category_news_id!=0){
                    $this->db->where('lock_list_id',$category_news_id);
                    if($this->db->update('lock_list',$data)){
                         return true;
                    }else{
                         return false;
                    }
             }else{
                    if($this->db->insert('lock_list',$data)){
                        return true;
                    }else{
                        return false;
                    }
            }
    }
    function get_num_data($arr_search){
            /*Begin search*/
            switch($arr_search['field_search'])
            {
                    case 'notice':
                            $this->db->like('notice',$arr_search['key_search']);
                            break ;
                    
            }
            /*End search*/
            $this->db->where('bl_active <>',-1);
             $query = $this->db->get('lock_list');
             return $query->num_rows();
    }
    function get_all_data($num,$offset,$arr_search)
    {
            /*Begin search*/
            switch($arr_search['field_search'])
            {
                    case 'notice':
                            $this->db->like('notice',$arr_search['key_search']);
                            break ;
                    
            }
            /*End search*/

            $this->db->where('bl_active <> ',-1);
             $this->db->order_by('lock_list_id','ASC');
             $query = $this->db->get('lock_list',$num,$offset);
             return $query->result();
    }
	 
	
  }
?>
